<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header"></head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="modal fade" id="modal-viewAdj">
    <div class="modal-dialog" style="width:80%">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">查看库存调整</h4>
            </div>
            <div class="modal-body">
                <form id="halfAdjViewForm" class="form-horizontal">
                    <input type="hidden" name="id" id="id">
                    <div class="row">
                        <div class="col-xs-12">
                            <div class="col-md-6">
                                <h4 class="text-center">调整前</h4>
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">物料描述</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="aadBeforeMatName" placeholder="" readonly="readonly">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">在库数量</label>
                                    <div class="col-sm-8">
                                        <input type="value" class="form-control" name="aadBeforeNum" placeholder="" readonly="readonly">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">单价（元）</label>
                                    <div class="col-sm-8">
                                        <input type="value" class="form-control" name="aadBeforePrice" placeholder="" readonly="readonly">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">单位</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="aadBeforeUnit" placeholder="" readonly="readonly">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">图号</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="aadBeforeDrawingNo" placeholder="" readonly="readonly">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">品牌</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="aadBeforeBrand" placeholder="" readonly="readonly">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">项目编号</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="aadBeforeProjectCode" placeholder="" readonly="readonly">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">项目名称</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="aadBeforeProjectName" placeholder="" readonly="readonly">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">部位名称</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="aadBeforePart" placeholder="" readonly="readonly">
                                    </div>
                                </div>
                                <!--<div class="form-group">-->
                                    <!--<label class="col-sm-4 control-label">存放状态</label>-->
                                    <!--<div class="col-sm-8">-->
                                        <!--<input type="text" class="form-control" name="aadBeforeMakingPiecesStatus" placeholder="" readonly="readonly">-->
                                    <!--</div>-->
                                <!--</div>-->
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">物料分类</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="aadBeforeMatType" placeholder="" readonly="readonly">
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <h4 class="text-center">调整后</h4>
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">物料描述</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="aadAfterMatName" id="aadAfterMatName"  placeholder="" readonly="readonly">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">在库数量</label>
                                    <div class="col-sm-8">
                                        <input type="value" class="form-control" name="aadAfterNum" placeholder="" readonly="readonly">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">单价（元）</label>
                                    <div class="col-sm-8">
                                        <input type="value" class="form-control" name="aadAfterPrice"  placeholder="" readonly="readonly">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">单位</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="aadAfterUnit" placeholder="" readonly="readonly">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">图号</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="aadAfterDrawingNo" placeholder="" readonly="readonly">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">品牌</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="aadAfterBrand" placeholder="" readonly="readonly">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">项目编号</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="aadAfterProjectCode" placeholder="" readonly="readonly">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">项目名称</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="aadAfterProjectName" placeholder="" readonly="readonly">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">部位名称</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="aadAfterPart" placeholder="" readonly="readonly">
                                    </div>
                                </div>
                                <!--<div class="form-group">-->
                                    <!--<label class="col-sm-4 control-label">存放状态</label>-->
                                    <!--<div class="col-sm-8">-->
                                        <!--<input type="text" class="form-control" name="aadAfterMakingPiecesStatus" placeholder="" readonly="readonly">-->
                                    <!--</div>-->
                                <!--</div>-->
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">物料分类</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="aadAfterMatType" placeholder="" readonly="readonly">
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">调整原因</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" name="aadAfterSpecialInstructions" placeholder="" readonly="readonly">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="modal-viewCreatAdj">
    <div class="modal-dialog" style="width:80%">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">查看新增库存调整</h4>
            </div>
            <div class="modal-body">
                <form id="halfAdjViewCreatForm" class="form-horizontal">
                    <input type="hidden" name="creatId" id="creatId">
                    <div class="row">
                        <div class="col-xs-12">
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">物料描述</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="aadAfterMatName"  placeholder="" readonly="readonly">
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">在库数量</label>
                                    <div class="col-sm-8">
                                        <input type="value" class="form-control" name="aadAfterNum" placeholder="" readonly="readonly">
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">单价（元）</label>
                                    <div class="col-sm-8">
                                        <input type="value" class="form-control" name="aadAfterPrice" placeholder="" readonly="readonly">
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">单位</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="aadAfterUnit"  placeholder="" readonly="readonly">
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">图号</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="aadAfterDrawingNo" placeholder="" readonly="readonly">
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">品牌</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="aadAfterBrand" placeholder="" readonly="readonly">
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">SAP物料编码</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="aadAfterSapMatCode" placeholder="" readonly="readonly">
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">项目编号</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="aadAfterProjectCode" placeholder="" readonly="readonly">
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">项目名称</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="aadAfterProjectName" placeholder="" readonly="readonly">
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">部位名称</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="aadAfterPart" placeholder="" readonly="readonly">
                                    </div>
                                </div>
                            </div>
                            <!--<div class="col-md-6">-->
                                <!--<div class="form-group">-->
                                    <!--<label class="col-sm-4 control-label">存放状态</label>-->
                                    <!--<div class="col-sm-8">-->
                                        <!--<input type="text" class="form-control" name="aadAfterMakingPiecesStatus" placeholder="" readonly="readonly">-->
                                    <!--</div>-->
                                <!--</div>-->
                            <!--</div>-->
                            <!--<div class="col-md-6">-->
                                <!--<div class="form-group">-->
                                    <!--<label class="col-sm-4 control-label">是否成品</label>-->
                                    <!--<div class="col-sm-8">-->
                                        <!--<input type="text" class="form-control" name="aadAfterIfFinishedProduct" placeholder="" readonly="readonly">-->
                                    <!--</div>-->
                                <!--</div>-->
                            <!--</div>-->
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">区位</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="aadAfterPosition" placeholder="" readonly="readonly">
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">仓位</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="aadAfterWhiName" placeholder="" readonly="readonly">
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">跟踪号</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="aadAfterTrackCode" placeholder="" readonly="readonly">
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">物料分类</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="aadAfterMatType" placeholder="" readonly="readonly">
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">箱号</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="aadAfterCaseNo" placeholder="" readonly="readonly">
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">装箱日期</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="aadAfterBoxingDate" placeholder="" readonly="readonly">
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">在库类型</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="aadAfterStockType" placeholder="" readonly="readonly">
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">备注</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="aadAfterRemark" placeholder="" readonly="readonly">
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">调整原因</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" name="aadAfterSpecialInstructions" placeholder="" readonly="readonly">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="modal-edit">
    <div class="modal-dialog" style="width:80%">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">修改库存调整</h4>
            </div>
            <div class="modal-body">
                <form id="halfAdjEditForm" class="form-horizontal">
                    <input type="hidden" id="aadId" name="aadId">
                    <input type="hidden" id="num" name="num">
                    <div class="row">
                        <div class="col-md-12">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-sm-4 control-label">物料描述</label>
                                <div class="col-sm-8">
                                    <input type="text" class="form-control" name="aadAfterMatName" placeholder="" readonly="readonly">
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-sm-4 control-label">在库数量</label>
                                <div class="col-sm-8">
                                    <input type="value" class="form-control" name="aadAfterNum" id="aadAfterNum" placeholder="" onkeyup="changeWeight(this)">
                                </div>
                            </div>
                        </div>
                        </div>
                        <div id="aluminumDiv">
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">材质</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="aadAfterTexture" id ="aadAfterTexture" placeholder="" readonly="readonly">
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">在库重量</label>
                                    <div class="col-sm-8">
                                        <input type="value" class="form-control" name="aadAfterWeight" id="aadAfterWeight" placeholder="" readonly="readonly">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-12">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-sm-4 control-label">单价（元）</label>
                                <div class="col-sm-8">
                                    <input type="value" class="form-control" name="aadAfterPrice" placeholder="" readonly="readonly">
                                </div>
                            </div>
                        </div>
                            <div id="aluminumDiv_unit">
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label">单位</label>
                                        <div class="col-sm-8">
                                            <input type="text" class="form-control" name="aadAfterUnit" placeholder="" readonly="readonly">
                                        </div>
                                    </div>
                                </div>
                            </div>

                        </div>
                        <div class="col-md-12">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-sm-4 control-label">图号</label>
                                <div class="col-sm-8">
                                    <input type="text" class="form-control" name="aadAfterDrawingNo" placeholder="" readonly ="readonly">
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-sm-4 control-label">品牌</label>
                                <div class="col-sm-8">
                                    <input type="text" class="form-control" name="aadAfterBrand" placeholder="" readonly ="readonly">
                                </div>
                            </div>
                        </div>
                        </div>
                        <div class="col-md-12">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-sm-4 control-label">SAP物料编码</label>
                                <div class="col-sm-8">
                                    <input type="text" class="form-control" name="aadAfterSapMatCode" placeholder="" readonly ="readonly">
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-sm-4 control-label">项目编号</label>
                                <div class="col-sm-8">
                                    <input type="text" class="form-control" name="aadAfterProjectCode" placeholder="" readonly ="readonly">
                                </div>
                            </div>
                        </div>
                        </div>
                        <div class="col-md-12">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-sm-4 control-label">项目名称</label>
                                <div class="col-sm-8">
                                    <input type="text" class="form-control" name="aadAfterProjectName" placeholder="" readonly ="readonly">
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-sm-4 control-label">部位名称</label>
                                <div class="col-sm-8">
                                    <input type="text" class="form-control" name="aadAfterPart" placeholder="" readonly ="readonly">
                                </div>
                            </div>
                        </div>
                        </div>
                        <div class="col-md-12">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-sm-4 control-label">区位</label>
                                <div class="col-sm-8">
                                    <input type="text" class="form-control" name="aadAfterPosition" placeholder="" readonly ="readonly">
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-sm-4 control-label">仓位</label>
                                <div class="col-sm-8">
                                    <input type="text" class="form-control" name="aadAfterWhiName" placeholder="" readonly ="readonly">
                                </div>
                            </div>
                        </div>
                        </div>
                        <div class="col-md-12">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-sm-4 control-label">跟踪号</label>
                                <div class="col-sm-8">
                                    <input type="text" class="form-control" name="aadAfterTrackCode" placeholder="" readonly ="readonly">
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-sm-4 control-label">物料分类</label>
                                <div class="col-sm-8">
                                    <input type="hidden" class="form-control" name="aadAfterMatType" placeholder="" readonly="readonly">
                                    <input type="text" class="form-control" id="aadAfterMatType" placeholder="" readonly="readonly">
                                </div>
                            </div>
                        </div>
                        </div>
                        <div class="col-md-12">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-sm-4 control-label">箱号</label>
                                <div class="col-sm-8">
                                    <input type="text" class="form-control" name="aadAfterCaseNo" placeholder="" readonly ="readonly">
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-sm-4 control-label">装箱日期</label>
                                <div class="col-sm-8">
                                    <input type="text" class="form-control" name="aadAfterBoxingDate" placeholder="" readonly ="readonly">
                                </div>
                            </div>
                        </div>
                        </div>
                        <div class="col-md-12">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-sm-4 control-label">在库类型</label>
                                <div class="col-sm-8">
                                    <input type="hidden" class="form-control" name="aadAfterStockType" placeholder="" readonly="readonly">
                                    <input type="text" class="form-control" id="aadAfterStockType" placeholder="" readonly="readonly">
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-sm-4 control-label">备注</label>
                                <div class="col-sm-8">
                                    <input type="text" class="form-control" name="aadAfterRemark" placeholder="" readonly ="readonly">
                                </div>
                            </div>
                        </div>
                        </div>
                        <div class="col-md-12">
                        <div class="col-md-12">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">调整原因</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control" name="aadAfterSpecialInstructions" placeholder="">
                                </div>
                            </div>
                        </div>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-info" id="btn-adj-save" shiro:hasPermission="halinv:haladjapp:edit">保存</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>

<section class="content-header">
    <h1>库存调整列表</h1>
</section>
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <form id="queryForm">
                        <div class="row">
                            <div class="form-inline">
                                <div class="form-group">
                                    <label>项目编号</label>
                                    <input type="text" name="aadAfterProjectCode" class="form-control" placeholder="请输入项目编号">
                                </div>
                                <div class="form-group">
                                    <label>项目名称</label>
                                    <input type="text" name="aadAfterProjectName" class="form-control" placeholder="请输入项目名称">
                                </div>

                                <div class="form-group" >
                                    <label>物料描述</label>
                                    <input type="text" name="aadAfterMatName" class="form-control" placeholder="请输入物料描述">
                                </div>

                                <div class="form-group">
                                    <label>仓库</label>
                                    <select name="aadAfterWhiId" class="form-control">
                                        <option value="" selected="selected">全部</option>
                                        <option th:each="whiIds:${whiIds}" th:value="${whiIds.whiId}"
                                                 th:text="${whiIds.whiName}"></option>
                                    </select>
                                </div>
                                <div class="form-group" >
                                    <label>调整状态</label>
                                    <select name="aadStatus" class="form-control">
                                        <option value=1 selected="selected">未提交</option>
                                        <option value=2>未审核</option>
                                        <option value=3>审核通过</option>
                                        <option value=4>审核未通过</option>
                                        <option value="">全部</option>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label>申请日期</label>
                                    <input type="text" class="form-control datepicker" name="startDate"/>
                                    <span>至</span>
                                    <input type="text" class="form-control datepicker"  name="endDate"/>
                                </div>
                                <button type="button" class="btn btn-success" id="btn-search">
                                    <span class="Bold">&emsp;搜索&emsp;</span>
                                </button>
                            </div>
                        </div>
                        <div id="toolbar">
                            <a type="button" class="btn btn-info pull-right" style="margin-right: 10px" th:href="@{/half/halInvManage/halfInveAdjApply/invList}" shiro:hasPermission="halinv:haladjlist:edit">
                                <span class="Bold">添加调整</span>
                            </a>
                            <button type="button"  class="btn btn-success pull-right"  style="margin-right: 10px" id="btn-submit" shiro:hasPermission="halinv:haladjlist:edit">
                                <span class="Bold">提交调整</span>
                            </button>

                        </div>
                    </form>
                </div>
                <div class="box-body">
                    <table id="bootstrap-table"></table>
                </div>
            </div>
        </div>
    </div>
</section>

<div th:include="include :: footer"></div>

<script th:inline="javascript">

    function changeWeight() {
        if($("#aadAfterMatType").val() == "铝料"){
            var a = parseFloat($("#aadAfterNum").val());
            var b = parseFloat($("#num").val());
            var c = Math.round(a*b*1000)/1000;
            $("#aadAfterWeight").val(c);
        }

    }
    /**
     * 打开修改库存模态框
     */
    function openEditAdj(aadId) {
        js.post({
            url: ctx+"half/halInvManage/halfInveAdjApply/editOpen",
            data: {
                id: aadId
            },
            success:function (result) {
                $('#aadId').val(aadId);
                $('#halfAdjEditForm').fillData(result);
                $("#aadAfterMatType").val(result.aadAfterMatType);
                $("#aadAfterStockType").val(result.aadAfterStockType);
                if($("#aadAfterMatType").val() == 2){
                    $("#aluminumDiv").hide();
                    $("#aluminumDiv_unit").show();
                }else if($("#aadAfterMatType").val() == 4){
                    $("#aluminumDiv").show();
                    $("#aluminumDiv_unit").hide();
                    $("#num").val(result.aadAfterWeight/result.aadAfterNum) ;
                }
                if($("#aadAfterMatType").val() == 1){
                    $("#aadAfterMatType").val("外购件");
                }else if($("#aadAfterMatType").val() == 2){
                    $("#aadAfterMatType").val("外协件");
                }else if($("#aadAfterMatType").val() == 3){
                    $("#aadAfterMatType").val("制作件");
                }else if($("#aadAfterMatType").val() == 4){
                    $("#aadAfterMatType").val("铝料");
                }else {
                    $("#aadAfterMatType").val("");
                }

                if($("#aadAfterStockType").val() == 1){
                    $("#aadAfterStockType").val("库存在库");
                }else if($("#aadAfterStockType").val() == 2){
                    $("#aadAfterStockType").val("项目在库");
                }else $("#aadAfterStockType").val("");
                js.modal.open("modal-edit");
                js.modal.closeLoading();
            }
        })
    }

    /**
     *删除库存变更
     */
    function delAdj(aadId) {
        js.modal.confirm("确认删除此变更吗？", function () {
            js.post({
                url: ctx + "half/halInvManage/halfInveAdjApply/del",
                data: {
                    aadId: aadId,
                    aadStatus: 0
                },
                success: function (result) {
                    if (result.type === web_status.SUCCESS) {
                        js.modal.success(result.msg);
                        js.table.refresh(table);
                    } else {
                        js.modal.warning(result.msg);
                    }
                    js.modal.closeLoading();
                }
            })
        })
    }

    /**
     * 查看库存调整申请
     */
    function openViewAdj(aadId) {
        js.post({
            url: ctx+"half/halInvManage/halfInveAdjApply/viewAdj",
            data: {
                id: aadId
            },
            success:function (result) {
                $('#id').val(aadId);
                $('#creatId').val(aadId);
                $("#halfAdjViewForm").fillData(result);
                $("#halfAdjViewCreatForm").fillData(result);
                var differBorderColor = "red";
                var sameBorderColor = "#d2d6de";
                var borderColor = "";
                if ((result.aadBeforeMatName == null || result.aadBeforeMatName == '') &&
                    (result.aadBeforePrice == null || result.aadBeforePrice == '') &&
                    (result.aadBeforeUnit == null || result.aadBeforeUnit == '') &&
                    (result.aadBeforeNum == null || result.aadBeforeNum == '')) {
                    $("#halfAdjViewCreatForm input[name ='aadAfterPrice']").css("border-color", sameBorderColor);
                    $("#halfAdjViewCreatForm input[name ='aadAfterUnit']").css("border-color", sameBorderColor);
                    $("#halfAdjViewCreatForm input[name ='aadAfterMatName']").css("border-color", sameBorderColor);
                    $("#halfAdjViewCreatForm input[name ='aadAfterNum']").css("border-color", sameBorderColor);

                    if($("#halfAdjViewCreatForm input[name ='aadAfterMatType']").val() == 1){
                        $("#halfAdjViewCreatForm input[name ='aadAfterMatType']").val("外购件");
                    }else if($("#halfAdjViewCreatForm input[name ='aadAfterMatType']").val() == 2){
                        $("#halfAdjViewCreatForm input[name ='aadAfterMatType']").val("外协件");
                    }else if($("#halfAdjViewCreatForm input[name ='aadAfterMatType']").val() == 3){
                        $("#halfAdjViewCreatForm input[name ='aadAfterMatType']").val("制作件");
                    }else $("#halfAdjViewCreatForm input[name ='aadAfterMatType']").val("");

                    if($("#halfAdjViewCreatForm input[name ='aadAfterStockType']").val() == 1){
                        $("#halfAdjViewCreatForm input[name ='aadAfterStockType']").val("库存在库");
                    }else if($("#halfAdjViewCreatForm input[name ='aadAfterStockType']").val() == 2){
                        $("#halfAdjViewCreatForm input[name ='aadAfterStockType']").val("项目在库");
                    }else $("#halfAdjViewCreatForm input[name ='aadAfterStockType']").val("");
                    js.modal.open("modal-viewCreatAdj");
                    js.modal.closeLoading();
                }else {
                    if (result.aadBeforePrice != result.aadAfterPrice) {
                        borderColor = differBorderColor;
                    } else {
                        borderColor = sameBorderColor;
                    }
                    $("#halfAdjViewForm input[name ='aadAfterPrice']").css("border-color", borderColor);

                    if (result.aadBeforeNum != result.aadAfterNum) {
                        borderColor = differBorderColor;
                    } else {
                        borderColor = sameBorderColor;
                    }
                    $("#halfAdjViewForm input[name ='aadAfterNum']").css("border-color", borderColor);

                    if (result.aadBeforeUnit != result.aadAfterUnit) {
                        borderColor = differBorderColor;
                    } else {
                        borderColor = sameBorderColor;
                    }
                    $("#halfAdjViewForm input[name ='aadAfterUnit']").css("border-color", borderColor);

                    if (result.aadBeforeMatName != result.aadAfterMatName) {
                        borderColor = differBorderColor;
                    } else {
                        borderColor = sameBorderColor;
                    }
                    $("#halfAdjViewForm input[name ='aadAfterMatName']").css("border-color", borderColor);

                    if($("#halfAdjViewForm input[name ='aadBeforeMatType']").val() == 1){
                        $("#halfAdjViewForm input[name ='aadBeforeMatType']").val("外购件");
                    }else if($("#halfAdjViewForm input[name ='aadBeforeMatType']").val() == 2){
                        $("#halfAdjViewForm input[name ='aadBeforeMatType']").val("外协件");
                    }else if($("#halfAdjViewForm input[name ='aadBeforeMatType']").val() == 3){
                        $("#halfAdjViewForm input[name ='aadBeforeMatType']").val("制作件");
                    }else $("#halfAdjViewForm input[name ='aadBeforeMatType']").val("");

                    if($("#halfAdjViewForm input[name ='aadBeforeStockType']").val() == 1){
                        $("#halfAdjViewForm input[name ='aadBeforeStockType']").val("库存在库");
                    }else if($("#halfAdjViewForm input[name ='aadBeforeStockType']").val() == 2){
                        $("#halfAdjViewForm input[name ='aadBeforeStockType']").val("项目在库");
                    }else $("#halfAdjViewForm input[name ='aadBeforeStockType']").val("");


                    if($("#halfAdjViewForm input[name ='aadAfterMatType']").val() == 1){
                        $("#halfAdjViewForm input[name ='aadAfterMatType']").val("外购件");
                    }else if($("#halfAdjViewForm input[name ='aadAfterMatType']").val() == 2){
                        $("#halfAdjViewForm input[name ='aadAfterMatType']").val("外协件");
                    }else if($("#halfAdjViewForm input[name ='aadAfterMatType']").val() == 3){
                        $("#halfAdjViewForm input[name ='aadAfterMatType']").val("制作件");
                    }else $("#halfAdjViewForm input[name ='aadAfterMatType']").val("");

                    if($("#halfAdjViewForm input[name ='aadAfterStockType']").val() == 1){
                        $("#halfAdjViewForm input[name ='aadAfterStockType']").val("库存在库");
                    }else if($("#halfAdjViewForm input[name ='aadAfterStockType']").val() == 2){
                        $("#halfAdjViewForm input[name ='aadAfterStockType']").val("项目在库");
                    }else $("#halfAdjViewForm input[name ='aadAfterStockType']").val("");
                    js.modal.open("modal-viewAdj");
                    js.modal.closeLoading();
                }
            }
        })
    }

    /**
     *全选
     */
    function selectedAll() {
        if ($('.checkboxAll').is(":checked")) {
            $('.checkbox_select').each(function () {
                this.checked = true;
            });
        } else {
            $('.checkbox_select').each(function () {
                this.checked = false;
            });
        }
    }
    
    var colors = ["label-default","label-warning", "label-info","label-success","label-danger"];
    var table;
    $(function () {
        /**
         * 加载列表
         */
        table = js.table.init({
            url: ctx + "half/halInvManage/halfInveAdjApply/list",
            showColumns: true,
            showExport: false,
            onLoadSuccess: function (data) {
                var dataSource = $('#bootstrap-table').bootstrapTable('getData', true);
                mergeCells(dataSource, "aadAdjOrderCode", 1, $('#bootstrap-table')); //合并单元格
            },
            columns: [
                {
                    title:'<input class="checkboxAll"  type="checkbox" onclick="selectedAll()" >',

                    // title: '<checkbox:true>',
                    formatter: function (value, row, index) {
                        if (row.aadStatus === 1) {
                            return '<input class="checkbox_select"  type="checkbox" name= "checkbox_select" value="' + $('<div/>').text(row.aadId).html() + '">';
                        } else {
                            return "";
                        }
                    }
                },
                {
                    title: '序号', field: 'id', width: '40',
                    formatter: function (value, row, index, field) {
                        return index + 1;
                    }
                },
                {title: '物料描述', field: 'aadAfterMatName', width: '350'},
                {title: '项目名称', field: 'aadAfterProjectName', width: '250'},
                {title: '项目编号', field: 'aadAfterProjectCode', width: '150'},
                {title: '图号', field: 'aadAfterDrawingNo', width: '150'},
                {title: '品牌', field: 'aadAfterBrand', width: '150'},
                {title: '损溢数量', field: 'ajaDeOvNum'},
                {title: '损溢重量', field: 'ajaDeOvWeight',
                    formatter: function (value, row, index) {
                        return Math.round(value*1000)/1000;
                    }},
                {title: '单位', field: 'aadAfterUnit', width: '80'},
                {title: '单价</br>（元）', field: 'aadAfterPrice'},
                {title: '损溢差额</br>（元）', field: 'aadAfterPrice',
                    formatter: function (value, row, index) {
                        if(row.aadAfterMatType == 4){
                            return Math.round(row.ajaDeOvWeight*row.aadAfterPrice*1000)/1000;
                        }else {
                            return row.ajaDeOvNum*row.aadAfterPrice;
                        }
                    }},
                {title:'申请人',field:'aadApplicant', width: '150'},
                {title: '申请时间', field:'aadApplDate', width: '150'},
                {title: '状态', field:'aadStatus', width: '150',
                    formatter: function (value, row, index) {
                        if (value === 1) {
                            return '<span class="badge ' + colors[value] + '">' + '未提交' + '</span> ';
                        }else if (value === 2) {
                            return '<span class="badge ' + colors[value] + '">' + '未审核' + '</span> ';
                        }else if(value === 3){
                            return '<span class="badge ' + colors[value] + '">' + '审核通过' + '</span> ';
                        }else if(value === 4){
                            return '<span class="badge ' + colors[value] + '">' + '审核未通过' + '</span> ';
                        }
                    }
                },
                {
                    title: '操作', width: '100',
                    formatter: function (value, row, index) {
                        var actions = [];
                        if (row.aadStatus === 1 ) {
                            if (row.aadBeAfFlag != 1)//调整单为前单，不显示编辑按钮
                            {
                                if (hasP("halinv:haladjlist:edit")) {
                                    actions.push('<a class="btn btn-warning btn-xs" href="javascript:void(0)" onclick="openEditAdj(' + row.aadId + ')"> 编辑</a> ');
                                }
                            }else if (row.aadBeAfFlag === 1){
                                if (hasP("halinv:haladjlist:view")) {
                                    actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="openViewAdj(' + row.aadId + ')"> 查看</a> ');
                                }
                            }else return actions.join('');
                            if (hasP("halinv:haladjlist:edit")) {
                                actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="delAdj(' + row.aadId + ')"> 删除</a>');
                            }
                        }else if (row.aadStatus === 2 || row.aadStatus === 3 || row.aadStatus ===4){
                            if (hasP("halinv:haladjlist:view")) {
                                actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="openViewAdj(' + row.aadId + ')"> 查看</a> ');
                            }
                        }
                        return actions.join('');
                    }
                }
            ]
        });

        /** 验证 */
        js.validate.init("halfAdjEditForm", {
            fields: {
                aadAfterNum: {validators:
                        {notEmpty: {message: '请输入在库数量'},
                            digits: {message: '请输入数值'}}}
                //aadAfterPrice:{validators: {digits: {message: '请输入数值'}}},
                //aadAfterUnit: {validators: {notEmpty: {message: '未输入单位'}}},
                //aadAfterName: {validators: {notEmpty: {message: '未输入物料描述'}}}
            }
        });

        /**
         * 保存修改库存调整
         */
        $("#btn-adj-save").click(function(aadId){
            js.validSubmit({
                formId: "halfAdjEditForm",
                url: ctx + "half/halInvManage/halfInveAdjApply/editSave",
                data: new FormData($("#halfAdjEditForm")[0]),
                success: function (result) {
                    if (result.type === web_status.SUCCESS) {
                        js.modal.success(result.msg);
                        js.modal.hide("modal-edit");
                        js.table.refresh(table);
                    } else {
                        js.modal.warning(result.msg);
                    }
                    js.modal.closeLoading();
                }
            });
        });

        // 批量提交
        $("#btn-submit").click(function () {
            //获取checkbox[name='check']的值
            var arr = new Array();
            $('input[name="checkbox_select"]:checkbox:checked').each(function(i,value){
                    arr += $(this).attr("value")+",";
            });
            if (arr.length <= 0) {
                js.modal.warning("请至少选择一个标记信息");
                return false;
            }
            arr = arr.substring(0,arr.length-1);
            js.modal.confirm("确定要批量提交库存调整吗?", function () {
                js.post({
                    url: ctx + "half/halInvManage/halfInveAdjApply/submit",
                    data: {arr : arr},
                    success: function (result) {
                        if (result.type === web_status.SUCCESS) {
                            js.modal.success(result.msg);
                            js.table.refresh(table);
                        } else {
                            js.modal.warning(result.msg);

                        }
                        js.modal.closeLoading();
                        location.reload();
                    }
                })
            });
        });

        /**
         * 合并单元格
         * @param data 原始数据（在服务端完成排序）
         * @param fieldName 合并依据属性名称
         * @param spanFieldName 合并属性名称
         * @param colspan 合并列
         * @param target 目标表格对象
         */
        function mergeCells(data, fieldName, colspan, target) {
            var valueArry = new Array();//数组只记录值
            for (var i = 0; i < data.length; i++) {
                for (var prop in data[i]) {
                    if (prop == fieldName) {
                        var key = data[i][prop]
                        valueArry[i] = key;
                        break;
                    }
                }
            }

            var numArry = new Array();//记录值出现的次数  一会就通过循环次数组  合并单元格
            var value = valueArry[0];//初始值
            var num = 0;//记录值出现的次数
            var index1 = 0;//numArry的下标
            for (var i = 0; i <= valueArry.length; i++) {
                if (i == valueArry.length) {//解决最后一次赋值
                    numArry[index1] = num;
                    break;
                }
                if (value == valueArry[i]) {
                    num++;//list下一个值与变量value值相同时，num+1，下标不变
                } else {
                    value = valueArry[i];//如果值不相等就把下一个值   赋值给value变量
                    numArry[index1] = num;//把value变量之前的值 出现的次数记录下来
                    num = 1;// 新的value值出现一次
                    index1++;//下标+1;
                }
            }

            var index = 0;
            var fiedArry = ["aadStatus"];
            for (var i = 0; i < numArry.length; i++) {
                var count = numArry[i] * 1;
                fiedArry.forEach(function (field) {
                    $(target).bootstrapTable('mergeCells', {
                        index: index,
                        field: field,
                        colspan: colspan,
                        rowspan: count
                    });
                });
                index += count;
            }
        }

        /**
         * 表格搜索
         */
        $("#btn-search").click(function () {
            js.table.search(table);
        });

        /**
         * 模态框隐藏事件， 重置表单，重置验证
         */
        js.modal.hideEvent("modal-edit", function () {
            js.validate.reset("halfAdjEditForm");
            js.reset("halfAdjEditForm");
        });
    });
</script>
</body>
</html>